package com.sojoys.artifact.manager;

import com.sojoys.artifact.factory.message.IMessage;
import com.sojoys.artifact.factory.message.IMessageFactory;
import com.sojoys.artifact.factory.message.SimpleMessageFactory;

/**
 * @author : DengYing
 * @CreateDate : 2017年8月14日 下午2:38:30
 * @Description ：Please describe this document
 */
public class MessageManager {
	private MessageManager() {
	}

	private static MessageManager ME = new MessageManager();

	public static MessageManager me() {
		return ME;
	}
	
	private IMessageFactory factory = new SimpleMessageFactory();
	
	public void getF(){
		factory.create();
	}
	
	public void setFactory(IMessageFactory factory) {
		this.factory = factory;
	}

	public IMessage create() {
		return factory.create();
	}
	
	public IMessage create(short commandId,byte[] body) {
		IMessage msg = factory.create();
		msg.setCommandId(commandId);
		msg.setBody(body);
		return msg;
	}
	
	public IMessage create(short commandId,int status) {
		IMessage msg = factory.create();
		msg.setCommandId(commandId);
		msg.setStatus(status);
		return msg;
	}
}
